/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.pg.misra.Actions;

import java.util.List;
import javax.swing.JTable;
import org.openide.windows.WindowManager;
import pl.pg.misra.GUI.ResultTopComponent;

/**
 *
 * @author Paweł
 */
public class AbstractAnalizer {
    
    protected void updateResultTable(List<String> ruleResult) {
        String[][] tableModel = new String[ruleResult.size()][4];
        int counter = 1;
        
        for(String rule : ruleResult){
            tableModel[counter - 1][0] = Integer.toString(counter);
            tableModel[counter - 1][1] = rule.split("\\|")[0];
            tableModel[counter - 1][2] = rule.split("\\|")[1];
            tableModel[counter - 1][3] = rule.split("\\|")[2];
            counter++;
        }
        
        ResultTopComponent resultComponent = (ResultTopComponent) WindowManager.getDefault().findTopComponent("ResultTopComponent");
        
        JTable jtable = resultComponent.getjTable1();
        
        jtable.setModel(new javax.swing.table.DefaultTableModel(
            tableModel,
            new String [] {
                "No", "File", "Line", "Message"
            }
        ));
        
        resultComponent.open();
    }
    
}
